package VWorldGameStudio;

import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.HashMap;
import java.util.function.BiConsumer;

import static FCRendering.FCRMaster.gameSave;

//专门用来传输同步角色血量等等的
public class FCPlayerTransport implements Serializable {

    public String hostId;

    public String name;

    // 等级
    public int level;
    // 血量
    public int blood;
    // 血量上限
    public int bloodMax;
    // 暴击值-战斗值
    public int crit;
    // 人物行走速度-速度
    public int speed1;
    // 坦克附加行走速度-驾驶
    public int speed2;
    // 修理成功数值-修理
    public int repair;
    // 抗毒、催眠等数值-强度
    public int strength;
    // 命中率-智力
    public int intell;
    // 体力值-当前最大体力值
    public int physical;
    // 剩余体力
    public int physicalnum;
    /**
     * 人物背包，总容量10
     */
   // public String[] knapsack;

    public HashMap<String, FCLongTermState> longTermMap = new HashMap<>();//战斗结束后遗留的状态放这里

    public FCPlayerTransport(FCPlayerInfo p){
        hostId = p.getAliasUID();
        name = p.getName();
        level = p.getLevel();
        blood = p.getBlood();
        bloodMax = p.getBloodMax();
        crit = p.getCrit();
        speed1 = p.getSpeed1();
        speed2 = p.getSpeed2();
        repair = p.getRepair();
        strength = p.getStrength();
        intell = p.getIntelligence();
        physical = p.getPhysical();
        physicalnum = p.getPhysicalnum();
        longTermMap = p.getLongTermMap();
    }



    public void setUpThePlayerInfo(FCPlayerInfo p){
        p.setBloodMax(bloodMax);
        p.setBlood(blood);
        p.setCrit(crit);
        p.setSpeed1(speed1);
        p.setSpeed2(speed2);
        p.setRepair(repair);
        p.setStrength(strength);
        p.setIntelligence(intell);
        p.setPhysical(physical);
        p.setPhysicalnum(physicalnum);
        p.getLongTermMap().clear();
        longTermMap.forEach(new BiConsumer<String, FCLongTermState>() {
            @Override
            public void accept(String s, FCLongTermState fcLongTermState) {
                p.getLongTermMap().put(s, fcLongTermState);
            }
        });
        if (p.isDeath() && p.getPlayertank1() != null && !p.getPlayertank1().equals("null") && p.getAliasUID().equals(gameSave.HOST_UID)) {
            gameSave.useTankOfPlayerId(p, p.getPlayertank1(), p.getPlayertankHostId());
            //下车
        }
    }
}
